//
//  YCDBTests.m
//  YCDBTests
//
//  Created by 唐可雄 on 2017/8/11.
//  Copyright © 2017年 swustyc. All rights reserved.
//

#import <XCTest/XCTest.h>

#import "YCDatabase.h"

@interface YCDBTests : XCTestCase

@end

@implementation YCDBTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

- (void)testOpen {
    NSURL *tempFolder = [NSURL fileURLWithPath:NSTemporaryDirectory()];
    NSURL *dbURL = [tempFolder URLByAppendingPathComponent:[[NSUUID UUID] UUIDString]];
    YCDatabase *database = [YCDatabase databaseWithURL:dbURL];
    XCTAssert(database, @"数据库没有返回");
    XCTAssertTrue([database open], "数据库没有开启");
    XCTAssertEqualObjects([database valueForKey:@"_url"], dbURL, @"数据库地址错误");
    XCTAssertTrue([database close], "数据库没有关闭");
    
    [[NSFileManager defaultManager] removeItemAtURL:dbURL error:nil];
}

@end
